const constantRoutes = [
  {
    path: '/redirect',
    component: 'layout/Layout',
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: 'views/redirect/index'
      }
    ]
  },
  {
    path: '/login',
    component: 'views/login/index',
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: 'views/login/auth-redirect',
    hidden: true
  },
  {
    path: '/404',
    component: 'views/error-page/404',
    hidden: true
  },
  {
    path: '/401',
    component: 'views/error-page/401',
    hidden: true
  },
  {
    path: '',
    component: 'layout/Layout',
    redirect: 'dashboard',
    children: [
      {
        path: 'dashboard',
        component: 'views/dashboard/index',
        name: 'Dashboard',
        meta: { title: '首页', icon: 'dashboard', affix: true }
      }
    ]
  },
]

const asyncRoutes = [
  {
    path: '/permission',
    component: 'layout/Layout',
    redirect: '/permission/index',
    alwaysShow: true,
    meta: {
      title: '权限管理',
      icon: 'lock',
      roles: ['admin', 'editor']
    },
    children: [
      {
        path: 'role',
        component: 'views/permission/role',
        name: 'RolePermission',
        meta: {
          title: '权限管理',
          roles: ['admin']
        }
      }
    ]
  },
  {
    path: '/usr',
    component: 'layout/Layout',
    redirect: '/usr/list',
    name: 'Usr',
    meta: {
      title: '用户管理',
      icon: 'course',
      roles: ['admin', 'editor']
    },
    children: [
      {
        path: 'create',
        component: 'views/usr/create',
        name: 'CreateUsr',
        meta: { title: '用户新增', roles: ['admin'] }
      },
      {
        path: 'edit/:id(\\d+)',
        component: 'views/usr/edit',
        name: 'EditUsr',
        meta: { title: '用户编辑', noCache: true },
        hidden: true
      },
      {
        path: 'list',
        component: 'views/usr/list',
        name: 'UsrList',
        meta: { title: '用户清单', icon: 'list' }
      }
    ]
  },
  {
    path: '/example',
    component: 'layout/Layout',
    redirect: '/example/list',
    name: 'Example',
    meta: {
      title: 'Example',
      icon: 'example'
    },
    children: [
      {
        path: 'create',
        component: 'views/example/create',
        name: 'CreateArticle',
        meta: { title: 'Create Article', icon: 'edit' }
      },
      {
        path: 'edit/:id(\\d+)',
        component: 'views/example/edit',
        name: 'EditArticle',
        meta: { title: 'Edit Article', noCache: true },
        hidden: true
      },
      {
        path: 'list',
        component: 'views/example/list',
        name: 'ArticleList',
        meta: { title: 'Article List', icon: 'list' }
      }
    ]
  },
  {
    path: '/res',
    component: 'layout/Layout',
    redirect: '/res/list',
    name: 'Res',
    meta: {
      title: '设备管理',
      icon: 'course',
      roles: ['admin', 'editor']
    },
    children: [
      {
        path: 'create',
        component: 'views/res/create',
        name: 'CreateRes',
        meta: { title: '设备新增', icon: 'edit', roles: ['admin'] }
      },
      {
        path: 'edit/:id(\\d+)',
        component: 'views/res/edit',
        name: 'EditRes',
        meta: { title: '设备编辑', noCache: true },
        hidden: true
      },
      {
        path: 'list',
        component: 'views/res/list',
        name: 'ResList',
        meta: { title: '设备清单', icon: 'list' }
      }
    ]
  },

  {
    path: '/edc',
    component: 'layout/Layout',
    redirect: '/edc/list',
    name: 'EDC',
    meta: {
      title: '参数管理',
      icon: 'course',
      roles: ['admin', 'editor']
    },
    children: [
      {
        path: 'create',
        component: 'views/edc/create',
        name: 'CreateEDC',
        meta: { title: '参数新增', icon: 'edit', roles: ['admin'] }
      },
      {
        path: 'edit/:id(\\d+)',
        component: 'views/edc/edit',
        name: 'EditEDC',
        meta: { title: '参数编辑', noCache: true },
        hidden: true
      },
      {
        path: 'list',
        component: 'views/edc/list',
        name: 'EDCList',
        meta: { title: '参数管理', icon: 'list' }
      }
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]

module.exports = {
  constantRoutes,
  asyncRoutes
}
